﻿#ifndef UDPUTILS_H
#define UDPUTILS_H
#include "GeneralTool/param.h"
#include <QDebug>
#include <QObject>
#include <QUdpSocket>
#include <QtNetwork>
class UDPUtils : public QObject {
    Q_OBJECT
public:
    explicit UDPUtils( const QString& clientAddr,          //
                       const int&     clientPort,          //
                                                           // const QString& serverAddr,             //
                       const bool& isShowChinese = false,  //
                       QObject*    parent        = nullptr );

    ~UDPUtils();

    void closeUDP();

    void sendData( QString ip, int port, QByteArray data );

private:
    QUdpSocket* udpsocket;
    bool        openOk = false;
    QString     client_addr;
    int         client_port;
    //  QString     server_addr;
    bool is_show_chinese;
signals:
    void sigReceiveData( const QString& ip, const QByteArray& data );
    void sigSendTips( QString, QString );
public slots:

    void sltOpenUDP();

    void sltReceiveData();
};

#endif  // UDPUTILS_H
